package ltd.dujiabao.bio;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author : DuJiabao
 * @Project : io_test
 * @Time : 2021/5/30 10:08
 * @Desc :
 */
public class Client {
  public static void main(String[] args) throws IOException {
    Socket socket = new Socket("127.0.0.1", 9999);  // 连接
    OutputStream outputStream = socket.getOutputStream();  // 获取输出流
    PrintStream printStream = new PrintStream(outputStream);  // 将输出流包装
    Scanner scanner = new Scanner(System.in);  // 获取用户输入
    while (true) {
      System.out.print("请说：");
      printStream.println(scanner.nextLine());  // 将用户输入放入到输出流中，给服务端
      printStream.flush();  // 输出完之后，flush一下
    }
  }
}
